//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for Route53Domains
public struct Route53DomainsErrorType: AWSErrorType {
    enum Code: String {
        case domainLimitExceeded = "DomainLimitExceeded"
        case duplicateRequest = "DuplicateRequest"
        case invalidInput = "InvalidInput"
        case operationLimitExceeded = "OperationLimitExceeded"
        case tLDRulesViolation = "TLDRulesViolation"
        case unsupportedTLD = "UnsupportedTLD"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize Route53Domains
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// The number of domains has exceeded the allowed threshold for the account.
    public static var domainLimitExceeded: Self { .init(.domainLimitExceeded) }
    /// The request is already in progress for the domain.
    public static var duplicateRequest: Self { .init(.duplicateRequest) }
    /// The requested item is not acceptable. For example, for APIs that accept a domain name, the request might specify a domain name that doesn't belong to the account that submitted the request. For AcceptDomainTransferFromAnotherAwsAccount, the password might be invalid.
    public static var invalidInput: Self { .init(.invalidInput) }
    /// The number of operations or jobs running exceeded the allowed threshold for the account.
    public static var operationLimitExceeded: Self { .init(.operationLimitExceeded) }
    /// The top-level domain does not support this operation.
    public static var tLDRulesViolation: Self { .init(.tLDRulesViolation) }
    /// Amazon Route 53 does not support this top-level domain (TLD).
    public static var unsupportedTLD: Self { .init(.unsupportedTLD) }
}

extension Route53DomainsErrorType: Equatable {
    public static func == (lhs: Route53DomainsErrorType, rhs: Route53DomainsErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension Route53DomainsErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
